#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

  struct TreeNode {
     int val;
      struct TreeNode *left;
      struct TreeNode *right;
  };

struct TreeNode* invertTree(struct TreeNode* root) {
    if (root == NULL)
    {
        return NULL;
    }
    struct TreeNode* tem = root->left;
    root->left = root->right;
    root->right = tem;
    invertTree(root->left);
    invertTree(root->right);
    return root;
}